#include "desencrypttest.h"

#include "common/logger/logger.h"

#ifdef Q_OS_WIN
#include <windows.h>
#endif

DESEncryptTest::DESEncryptTest(QObject* parent)
{
}
void DESEncryptTest::initTestCase()
{
	LOG_INFO("测试开始");
}
void DESEncryptTest::tstDESEncrypt()
{
	std::string plaintext = "12345678";
	LOG_INFO("明文：", plaintext);
	auto ciphertext = DESEncrypt::encrypt(plaintext);
	LOG_INFO("密文：", ciphertext);
	auto plaintext2 = DESEncrypt::decrypt(ciphertext);
	LOG_INFO("密文转明文：", plaintext2);

	LOG_INFO("base64加密: ", DESEncrypt::base64Encrypt(plaintext));
}
void DESEncryptTest::cleanupTestCase()
{
}

int main(int argc, char** argv)
{

	// 设置Windows控制台编码
#ifdef Q_OS_WIN
	// 设置控制台输出代码页为 UTF-8
	SetConsoleOutputCP(CP_UTF8);
	// 可选：设置控制台输入为 UTF-8
	SetConsoleCP(CP_UTF8);
#endif

	DESEncryptTest tc;
	return QTest::qExec(&tc, argc, argv);// qExec 会把失败信息打印到 stdout
}